import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TreeMap;

import org.apache.commons.codec.binary.Hex;

import com.bootdo.common.utils.HttpUtil;
import com.bootdo.system.config.KswApi;



public class ccccccc {
	public static void main(String[] args) {
		TreeMap<String,String> params=new TreeMap<String, String>();
		params.put("key","c85d5261e1b8b214d0706c9334a01c51");
		params.put("ts",getTimestamp());
		params.put("type","0");
		params.put("sign","sign");
		params.put("startTime","2020101010");
		params.put("endTime","2020121010");
		params.put("page","1");
		params.put("limit","10");
		params.put("queryTimeType","1");
		String genSign = genSign(params);
		params.put("sign",genSign);
		System.out.println(params.toString());
		String s = HttpUtil.httpGet("https://runion.meituan.com/api/orderList",params);
		   System.out.println(s);
	}
	
	public static String genSign(TreeMap<String,String> params) {
		String SECRET="34b62767dd121d71";
		if (params.containsKey("sign")) {
		    params.remove("sign");
		}
		String str = "";
		str += SECRET;
		for (String key : params.keySet()) {
		    str += key + params.get(key);
		}
		str += SECRET;
		String sign = md5(str);
		return sign;
	}
	public static String md5(String source) {
		String md5Result = null;
		try {
		        byte[] hash = org.apache.commons.codec.binary.StringUtils.getBytesUtf8(source);
		        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
		        messageDigest.update(hash);
		        hash = messageDigest.digest();
		        md5Result = Hex.encodeHexString(hash);
		} catch (NoSuchAlgorithmException e) {
		        e.printStackTrace();
		}
		return md5Result;
	}
	
	private static String getTimestamp() {
		SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhss");//设置日期格式
		String timestamp = df.format(new Date());
		return timestamp;
	}

}
